package com.dlc.yunguang.activitynew;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.dlc.commonlibrary.utils.TimeFormats;
import com.dlc.commonlibrary.widget.TitleBar;
import com.dlc.yunguang.adapter.RecycleOrderDetailAdapter;
import com.dlc.yunguang.base.BaseActivity;
import com.dlc.yunguang.net.bean.OrderDetailBean;
import com.dlc.yunguang.R;

import java.text.SimpleDateFormat;
import java.util.Date;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/7/20 0020.
 */

public class RecycleOrderDetailActivity extends BaseActivity {

    OrderDetailBean orderDetailBean;
    RecycleOrderDetailAdapter mOrderDetailAdapter;
    @BindView(R.id.titleBar)
    TitleBar mTitleBar;
    @BindView(R.id.company)
    TextView mCompany;
    //@BindView(R.id.hospital)
    //TextView mHospital;
    @BindView(R.id.send_wash_time)
    TextView mSendWashTime;
    @BindView(R.id.mRecyclerView)
    RecyclerView mRecyclerView;
    @BindView(R.id.print)
    Button mPrint;
    @BindView(R.id.wash_goods_hint)
    TextView mWashGoodsHint;
    @BindView(R.id.send_wash_code)
    TextView sendWashCode;
    @BindView(R.id.nums)
    TextView nums;
    //@BindView(R.id.hospital)
    //TextView mHospital;
    private boolean isBold, isUnderLine;
    int type;
    private int record;


    @Override
    protected int getLayoutID() {
        return R.layout.activity_dispense_detail;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mTitleBar.leftExit(this);

        Bundle bundle = getIntent().getExtras();

        orderDetailBean = (OrderDetailBean) bundle.getSerializable("detailData");

        if (orderDetailBean.data.spec_group.size() > 0) {
            InitRecyclerView(orderDetailBean);
            mCompany.setText(orderDetailBean.data.company);
        }

        mSendWashTime.setText(TimeFormats.formatDateTimeSecend(
            (long) Integer.parseInt(orderDetailBean.data.ctime) * 1000));

       // mHospital.setText(orderDetailBean.data.hotel + "-" + orderDetailBean.data.office);
        mWashGoodsHint.setText("回收单");
        sendWashCode.setText(orderDetailBean.data.orderno);
        nums.setText(orderDetailBean.data.nums);


        isBold = false;
        isUnderLine = false;
        mPrint.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = "";
                 String orderno = orderDetailBean.data.orderno;
                string = "";
                string = string  + "  "+orderDetailBean.data.hotel + "\r\n";

                string = string + "         " + "回收单" + "\r\n";
                string =string+"单    号："  +  orderno + "\r\n";
                string = string + "医院科室：" + orderDetailBean.data.office + "\r\n";

                string =string+"总 数 量：" +  orderDetailBean.data.nums + "\r\n";

                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date curDate = new Date(System.currentTimeMillis());
                String date = formatter.format(curDate);
                string = string + "日    期：" + date + "\r\n";

                //string = string + getString(R.string.client) + "：" + orderDetailBean.data.hotel_number + "\r\n";
                //string = string + "名    称：" + orderDetailBean.data.hotel + "\r\n";
                string = string + "-------------------------";
                for (int i = 0; i < orderDetailBean.data.spec_group.size(); i++) {
                    OrderDetailBean.DataBean.SpecGroupBean bean = orderDetailBean.data.spec_group.get(i);
                    string = string + "\r\n" +( bean.spec  + "   "+bean.count);
                    string = string + "\r\n" +("人员：" +bean.user);
                    string = string + "\r\n";
                }
                string = string + "-------------------------";
                string = string + "\r\n";

                string = string + "备注：" + "\r\n" ;
                string = string + "□ 污染"+ "\r\n";
                string = string + "□ 破损";
                string = string + "\r\n"+ "\r\n";
                string = string + getString(R.string.signature) + "：" + "\r\n" + "\r\n"+ "\r\n";
                string = string + "-------------------------";
                string = string + "\r\n"+ "\r\n";
                Intent intent = new Intent(getActivity(), SearchBTActivity.class);
                intent.putExtra(SearchBTActivity.key_string, string);
                startActivity(intent);
               // sendData(string, 22);
            }
        });
    }

    private void InitRecyclerView(final OrderDetailBean orderDetailBean) {
        mOrderDetailAdapter = new RecycleOrderDetailAdapter();
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setAdapter(mOrderDetailAdapter);
        if (orderDetailBean.data.spec_group != null) {
            mOrderDetailAdapter.addData(orderDetailBean.data.spec_group);
        }
    }





}
